package level4.iso
{
	import flash.display.Sprite;
	
	public class IsoWorld extends Sprite
	{
		private var floor:Sprite;
		private var world:Sprite;
		private var objectLists:Array = [];
		
		public function IsoWorld()
		{
			floor = new Sprite();
			world = new Sprite();
			addChild(floor);
			addChild(world);
		}
		
		public function addChildToFloor(obj:IsoObject):void{
			floor.addChild(obj);
		}
		
		public function addChildToWorld(obj:IsoObject):void{
			objectLists.push(obj);
			sort();
		}
		
		private function sort():void{
			objectLists.sortOn("depth",Array.NUMERIC);
			for(var i:int = 0;i<objectLists.length;i++){
				world.addChild(objectLists[i]);
			}
		}
	}
}